#include <iostream>
#include <vector>

using namespace std;
class Solution 
{
public:
    vector<int> plusOne(vector<int>& nums) 
    {
        int n = nums.size() - 1;
        while (nums[n] == 9 && n >= 0) 
        {
            nums[n] = 0;
            --n;
        }
        if (n >= 0) nums[n] += 1;
        else nums.insert(nums.begin(), 1);
        return nums;
    }
};

int main()
{
    vector<int> v{ 1,2,3 };

    Solution xz;
    for (auto e : xz.plusOne(v))
    {
        cout << e << ' ';
    }


    return 0;
}